package cn.blossoming.dao.domain;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;

import javax.persistence.*;
import java.time.LocalDateTime;
import java.util.List;

@Entity
@DynamicInsert
@DynamicUpdate
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "video_comment", schema = "blosson")
public class VideoCommentEntity {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer id;
    private String content;
    private Integer praiseNum;
    private Integer commentNum;
    private String remark;
    private LocalDateTime updateTime;
    private LocalDateTime createTime;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "video_id")
    private VideoEntity video;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "parent_id")
    private VideoCommentEntity videoComment;

    @OneToMany(mappedBy = "videoComment")
    private List<VideoCommentEntity> videoComments;

    @OneToMany(mappedBy = "videoComment")
    private List<VideoCommentPraiseEntity> videoCommentPraises;

    @ManyToOne
    @JoinColumn(name = "user_id")
    private UserEntity user;

}
